package 并发编程17.基于优先级的阻塞队列;

import 并发编程17.Consumer;
import 并发编程17.Provider;

import java.util.concurrent.*;

/**
 * @author idea
 * @data 2019/2/17
 */
public class Demo {


    public static void main(String[] args) throws InterruptedException {
        BlockingQueue<String> blockingQueue = new LinkedBlockingQueue<>(10);
        Provider provider1 = new Provider(blockingQueue);
        Provider provider2 = new Provider(blockingQueue);
        Provider provider3 = new Provider(blockingQueue);
        Consumer consumer = new Consumer(blockingQueue);
        ExecutorService executorService=new ScheduledThreadPoolExecutor(4);
        executorService.execute(provider1);
//        executorService.execute(provider2);
//        executorService.execute(provider3);
        executorService.execute(consumer);

        Thread.sleep(5000);
        executorService.shutdown();

    }
}
